# -*- coding: utf-8 -*-
from abc import ABC

from app.models.cod import ValkyrjaException, Error
from app.models.dao import vectors, vectorss
from app.views import CommonHandler
from app.models import db_session


class VectorsHandler(CommonHandler, ABC):
    async def get(self):
        meta_id = self.get_argument("meta_id", None)
        meta_version = self.get_argument("meta_version", None)
        try:
            data = vectors(meta_id,meta_version)
        except ValkyrjaException:
            await self.response(error=Error.NotMeta)
            return
        await self.response(data=data)

    async def post(self):
        params, session = self.json_params(), db_session()
        meta_ids = params['meta_ids']
        data = vectorss(meta_ids)
        await self.response(data=data)
